<!DOCTYPE html>
<html>
<head>
    <title>测试登录API</title>
</head>
<body>
    <h1>登录API测试</h1>
    <button onclick="testLogin()">测试登录</button>
    <div id="result"></div>

    <script>
        async function testLogin() {
            const resultDiv = document.getElementById('result');
            
            try {
                const response = await fetch('http://localhost:8080/api/login', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json'
                    },
                    body: JSON.stringify({
                        email: 'default@example.com',
                        password: 'password123'
                    })
                });

                const data = await response.json();
                
                if (response.ok) {
                    resultDiv.innerHTML = `
                        <h3 style="color: green;">登录成功!</h3>
                        <p>Token: ${data.token}</p>
                    `;
                } else {
                    resultDiv.innerHTML = `
                        <h3 style="color: red;">登录失败!</h3>
                        <p>错误: ${data.message}</p>
                    `;
                }
            } catch (error) {
                resultDiv.innerHTML = `
                    <h3 style="color: red;">请求错误!</h3>
                    <p>错误: ${error.message}</p>
                `;
            }
        }
    </script>
</body>
</html> 